<template>
  <el-dialog v-model="visible" modal-class="procure-editor-dialog" width="500" align-center center :show-close="false">
    <template #header>
      <p style="text-align: left; font-size: 18px; color: #131414">
        <i class="icon"></i>{{ title }}
        <span v-if="titleTips" class="f12" style="color: #86909c">（{{ titleTips }}）</span>
      </p>
    </template>

    <div class="content-wrap">
      <!-- 拒绝原因 -->
      <div class="refuse-wrap" v-if="refuseVal">
        <p class="mb10" style="color: #ff3333">拒绝原因</p>
        <div class="refuse-remark-info" v-html="refuseVal"></div>
      </div>
      <!-- 备注信息 -->
      <Editor v-model="textarea" :disabled="type === 'view' ? true : false" />
    </div>

    <template #footer>
      <div class="dialog-footer">
        <div class="mt20">
          <el-button class="jzt-button" type="info" @click="visible = false" style="width: 120px">{{ cancelBtnText }}</el-button>
          <el-button v-if="type !== 'view'" type="primary" @click="submit" style="width: 120px">{{ submitBtnText }}</el-button>
        </div>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { computed, ref } from "vue";
import Editor from "@/components/Editor";

const props = defineProps({
  isOpen: {
    type: Boolean,
    default: false
  },
  type: {
    type: String,
    default: "edit" //edit refuse view
  },
  title: {
    type: String,
    default: "发货确认"
  },
  titleTips: {
    type: String,
    default: ""
  },
  submitBtnText: {
    type: String,
    default: ""
  },
  cancelBtnText: {
    type: String,
    default: ""
  },
  refuseVal: {
    type: String,
    default: "" //拒绝原因 富文本编辑器的内容
  },
  message: {
    type: String,
    default: "---"
  },
  editorVal: {
    type: String,
    default: "" //富文本编辑器的内容
  }
});
const textarea = ref(props.editorVal);
// const editorDisabled = ref(false)
const emit = defineEmits(["update:isOpen", "submit"]);
const visible = computed({
  get() {
    return props.isOpen;
  },
  set(value) {
    emit("update:isOpen", value);
  }
});

const submit = () => {
  emit("submit");
};
</script>

<style scoped lang="scss">
:deep(.refuse-remark-info) {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid #dcdfe6;

  max-height: 150px;
  overflow: auto;
  img {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    margin: 10px 10px 0 0;
  }
  video {
    width: 130px;
    height: 80px;
  }
}
.content-wrap {
  margin-top: 10px;
  h1 {
    text-align: center;
  }
  .red-text {
    color: #ff3333;
    font-style: normal;
    display: block;
    text-align: center;
  }
  .gray-block {
    background-color: #f5f7fa;
    color: #3d3d3d;
    span {
      color: #86909c;
      line-height: 20px;
    }
  }
}

.title {
  color: #3d3d3d;
  font-size: 20px;
  margin-bottom: 32px;
}
.sure {
  text-align: center;
  span {
    font-size: 14px;
    color: #3d3d3d;
    line-height: 20px;
  }

  ::v-deep(.el-icon) {
    font-size: 60px;
    margin-bottom: 20px;
    color: rgb(255, 51, 51);
  }
}
.audit-dialog {
  .goods-detail {
    margin-bottom: 20px;
  }
}

.alert {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 54px;
  margin: 0 0 10px;
  background: #ffd9c2;
  border-radius: 6px;

  .el-icon {
    color: #e37318;
    margin: 0 10px;
  }
}

.dialog-footer-flex {
  display: flex;
  justify-content: space-between;
}
</style>
